#include <iostream>
#include <vector>

using namespace std;

class Solution
{
public:

    vector<string> findWords(vector<string>& words)
    {
        vector<string> ans;
        string rowidx{ "12210111011122000010020202" };
        for (auto word : words)
        {
            bool isvalid = true;
            char idx = rowidx[tolower(word[0]) - 'a'];
            for (int i = 1; i < word.size(); i++)
            {
                if (rowidx[tolower(word[i]) - 'a']!=idx)
                {
                    isvalid = false;
                    break;
                }
            }
            if (isvalid)
            {
                ans.emplace_back(word);
            }
        }

        return ans;
    }
};

int main()
{
    vector<string> words{ "Hello", "Alaska", "Dad", "Peace" };

    Solution xz;

    vector<string> v = xz.findWords(words);
    for (auto e : v)
    {
        cout << e << endl;
    }

	return 0;
}